import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsInt, IsNotEmpty, IsOptional, MaxLength, MinLength } from "class-validator";
import { PaginatedDto } from "src/common/dto";

export class CreatePermissionDto {
    @ApiProperty({ example: 'admin', description: '权限码' })
    @IsNotEmpty({
        message: '权限码不能为空'
    })
    @MinLength(1)
    @MaxLength(15)
    code: string

    @ApiProperty({ example: '可以操作admin相关接口', description: '权限的描述' })
    @IsOptional()
    description: string
}

export class DeletePermissionDto {
    @ApiProperty({ example: '1111', description: '权限id' })
    @IsNotEmpty({
        message: 'id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number
}

export class UpdatePermissionDto {
    @ApiProperty({ example: '1111', description: '权限id' })
    @IsNotEmpty({
        message: 'id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number

    @ApiProperty({ example: 'admin', description: '权限码' })
    @IsNotEmpty({
        message: '权限码不能为空'
    })
    @MinLength(1)
    @MaxLength(15)
    code: string

    @ApiProperty({ example: '可以操作admin相关接口', description: '权限的描述' })
    @IsOptional()
    description: string
}


export class FindManyPermissionDto extends PaginatedDto { }